﻿using System;
using System.Collections.Generic;
using Terraria.IO;

namespace Terraria.Social.Base
{
	// Token: 0x02000144 RID: 324
	public abstract class CloudSocialModule : ISocialModule
	{
		// Token: 0x06000DAB RID: 3499 RVA: 0x0000D7E4 File Offset: 0x0000B9E4
		public virtual void Initialize()
		{
			Main.Configuration.OnLoad += delegate(Preferences preferences)
			{
				this.EnabledByDefault = preferences.Get<bool>("CloudSavingDefault", false);
			};
			Main.Configuration.OnSave += delegate(Preferences preferences)
			{
				preferences.Put("CloudSavingDefault", this.EnabledByDefault);
			};
		}

		// Token: 0x06000DAC RID: 3500
		public abstract void Shutdown();

		// Token: 0x06000DAD RID: 3501
		public abstract IEnumerable<string> GetFiles();

		// Token: 0x06000DAE RID: 3502
		public abstract bool Write(string path, byte[] data, int length);

		// Token: 0x06000DAF RID: 3503
		public abstract void Read(string path, byte[] buffer, int length);

		// Token: 0x06000DB0 RID: 3504
		public abstract bool HasFile(string path);

		// Token: 0x06000DB1 RID: 3505
		public abstract int GetFileSize(string path);

		// Token: 0x06000DB2 RID: 3506
		public abstract bool Delete(string path);

		// Token: 0x06000DB3 RID: 3507 RVA: 0x003F8974 File Offset: 0x003F6B74
		public byte[] Read(string path)
		{
			byte[] array = new byte[this.GetFileSize(path)];
			this.Read(path, array, array.Length);
			return array;
		}

		// Token: 0x06000DB4 RID: 3508 RVA: 0x0000D812 File Offset: 0x0000BA12
		public void Read(string path, byte[] buffer)
		{
			this.Read(path, buffer, buffer.Length);
		}

		// Token: 0x06000DB5 RID: 3509 RVA: 0x0000D81F File Offset: 0x0000BA1F
		public bool Write(string path, byte[] data)
		{
			return this.Write(path, data, data.Length);
		}

		// Token: 0x040011FD RID: 4605
		public bool EnabledByDefault;
	}
}
